﻿Imports System.Data.SqlClient

Public Class CBan
#Region "attribute"
    Dim _strTenBan As String
    Dim _strMaBan As String
    Dim _iTinhTrang As Integer
    Dim _strKhuVuc As String
    Shared da As DataProvider
#End Region
#Region "property"
    Property TenBan
        Get
            Return _strTenBan
        End Get
        Set(ByVal value)
            _strTenBan = value
        End Set
    End Property
    Property MaBan
        Get
            Return _strMaBan
        End Get
        Set(ByVal value)
            _strMaBan = value
        End Set
    End Property
    Property TinhTrang
        Get
            Return _iTinhTrang
        End Get
        Set(ByVal value)
            _iTinhTrang = value
        End Set
    End Property
    Property KhuVuc
        Get
            Return _strKhuVuc
        End Get
        Set(ByVal value)
            _strKhuVuc = value
        End Set
    End Property
#End Region
    Public Sub LoadDanhSachBan(ByVal dsBan As List(Of CBan))
        Try
            da = New DataProvider
            da.OpenConnect()
            Dim cmd As New SqlCommand("select * from BAN", da.con)
            Dim dr As SqlDataReader
            dr = cmd.ExecuteReader()
            While dr.Read()
                Dim ban As New CBan
                ban.MaBan = dr.Item(0)
                ban.TenBan = dr.Item(1)
                ban.TinhTrang = dr.Item(2)
                ban.KhuVuc = dr.Item(3)
                dsBan.Add(ban)
            End While
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error")
        Finally
            da.CloseConnect()
        End Try
    End Sub
    'Public Sub UpdateTinhTrang(ByVal maban As Integer, ByVal state As Integer)
    '    Dim sql As String = "UPDATE BAN  SET TinhTrang = 1 " + state + " WHERE MaBan = '" + maban + "'"
    '    CKiemTra.Update(sql)
    'End Sub
End Class
